package cool.tianyou.blue.bird.config;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.DistributionSummary;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Liutianyou
 * @date 2022/3/2 12:01 上午
 */
@Component
public class PrometheusCustomMonitor {

  /**
   * 用户数
   */
  private Gauge userCount;

  /**
   * 客户端数量
   */
  private Gauge deviceCount;

  private Counter messagePushCount;


  private final MeterRegistry registry;

  @Autowired
  public PrometheusCustomMonitor(MeterRegistry registry) {
    this.registry = registry;
  }

  public void userCount(Integer userCount) {
    registry.gauge("userCount", userCount);
  }

  @PostConstruct
  private void init() {
    messagePushCount = registry.counter("message_push_count");
  }

  public void messageCountAdd(Integer count) {
    messagePushCount.increment(count);
  }


  public void clientCount(Integer clientCount) {
    registry.gauge("clientCount", clientCount);
  }


}
